import type fs from "node:fs/promises";
import type fss from "node:fs";

export function readFile(...args: Parameters<typeof fs.readFile>): Promise<Uint8Array> {
  return ipc.invoke("file:read", ...args);
}

export function readFileText(...args: Parameters<typeof fs.readFile>): Promise<string> {
  return ipc.invoke("file:read-text", ...args);
}

export function writeFile(...args: Parameters<typeof fs.writeFile>) {
  return ipc.invoke("file:write", ...args);
}

export function copyFile(...args: Parameters<typeof fs.copyFile>) {
  return ipc.invoke("file:copy-file", ...args);
}

export function existsFile(file: string): Promise<boolean> {
  return ipc.invoke("file:exists", file);
}

export function deleteFile(...args: Parameters<typeof fss.rmSync>) {
  return ipc.invoke("file:delete", ...args);
}

export function rename(...args: Parameters<typeof fss.renameSync>): Promise<boolean> {
  return ipc.invoke("file:rename", ...args);
}

export function linkFile(...args: Parameters<typeof fss.linkSync>) {
  return ipc.invoke("file:link", ...args);
}

export function symlinkFile(...args: Parameters<typeof fss.symlinkSync>) {
  return ipc.invoke("file:symlink", ...args);
}

export function unlinkFile(...args: Parameters<typeof fss.unlinkSync>) {
  return ipc.invoke("file:unlink", ...args);
}

export function readDir(dir: string): Promise<string[]> {
  return ipc.invoke("file:readdir", dir);
}
